Per-domain switch to disable oos shadow page tables
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Oct 2009 09:55:46 +0000 (10:55 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Oct 2009 09:55:46 +0000 (10:55 +0100)
Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
13 files changed:
tools/python/xen/xend/XendConfig.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/create.py
tools/python/xen/xm/xenapi_create.py
xen/arch/x86/domain.c
xen/arch/x86/mm/paging.c
xen/arch/x86/mm/shadow/common.c
xen/common/domctl.c
xen/include/asm-x86/domain.h
xen/include/asm-x86/paging.h
xen/include/asm-x86/shadow.h
xen/include/public/domctl.h
xen/include/xen/sched.h

index 8c70fab6129a14d68876007a4c2b1703091b1e5c..84f1f0f556ee7878561280b310c53aa2a0afc9d7 100644 (file)
@@ -178,6 +178,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
     'xen_platform_pci': int,
     "gfx_passthru": int,
     'description': str,
+    'oos' : int,
 }
 
 # Xen API console 'other_config' keys.
index e0891b46f33581d836ab8571ff6b2dd53b3f0b6f..98214d92ceb1246989b4ca6bd7db216108cba66e 100644 (file)
@@ -2419,7 +2419,11 @@ class XendDomainInfo:
         s3_integrity = 0
         if self.info.has_key('s3_integrity'):
             s3_integrity = self.info['s3_integrity']
-        flags = (int(hvm) << 0) | (int(hap) << 1) | (int(s3_integrity) << 2)
+
+        oos = self.info['platform'].get('oos', 1)
+        oos_off = 1 - oos
+
+        flags = (int(hvm) << 0) | (int(hap) << 1) | (int(s3_integrity) << 2) | (int(oos_off) << 3)
 
         try:
             self.domid = xc.domain_create(
index e47db2f1406296c51ad7139b4772ea926656ec63..4c71587d3f6ba34e3843c08ed8deeabde9af24e6 100644 (file)
@@ -610,6 +610,11 @@ gopts.var('s3_integrity', val='TBOOT_MEMORY_PROTECT',
           use="""Should domain memory integrity be verified during S3?
           (0=protection is disabled; 1=protection is enabled.""")
 
+gopts.var('oos', val='OOS',
+          fn=set_int, default=1,
+          use="""Should out-of-sync shadow page tabled be enabled?
+          (0=OOS is disabled; 1=OOS is enabled.""")
+
 gopts.var('cpuid', val="IN[,SIN]:eax=EAX,ebx=EBX,ecx=ECX,edx=EDX",
           fn=append_value, default=[],
           use="""Cpuid description.""")
@@ -990,7 +995,7 @@ def configure_hvm(config_image, vals):
              'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
              'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor',
              'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet',
-             'guest_os_type', 'hap', 'opengl', 'cpuid', 'cpuid_check',
+             'guest_os_type', 'hap', 'oos', 'opengl', 'cpuid', 'cpuid_check',
              'viridian', 'xen_extended_power_mgmt', 'pci_msitranslate',
              'vpt_align', 'pci_power_mgmt', 'xen_platform_pci',
              'gfx_passthru', 'description' ]
@@ -1038,6 +1043,8 @@ def make_config(vals):
         config.append(['backend', ['tpmif']])
     if vals.localtime:
         config.append(['localtime', vals.localtime])
+    if vals.oos:
+        config.append(['oos', vals.oos])
 
     config_image = configure_image(vals)
     if vals.bootloader:
index d8e9dc54c774121d4c14d07d5f03a12848a58bc0..1f8635717042271a6c8a13480723394c3cb34ea4 100644 (file)
@@ -1073,6 +1073,7 @@ class sxp2xml:
             'vhpt',
             'guest_os_type',
             'hap',
+            'oos',
             'pci_msitranslate',
             'pci_power_mgmt',
             'xen_platform_pci',
index 61a605e19fdbbce7bdfe25523c725413a07cba82..d5f216bd26276ad6c27ef61fef4a0d7d83685aed 100644 (file)
@@ -452,7 +452,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
 
 #endif /* __x86_64__ */
 
-    if ( (rc = paging_domain_init(d)) != 0 )
+    if ( (rc = paging_domain_init(d, domcr_flags)) != 0 )
         goto fail;
     paging_initialised = 1;
 
index 94b745f0fd7a7b910cbada6f1cf3c86d2e13d9be..77ed35f02a25e98156fe43c3bc79f4fd9939d3f3 100644 (file)
@@ -636,7 +636,7 @@ static void paging_log_dirty_teardown(struct domain*d)
 /*           CODE FOR PAGING SUPPORT            */
 /************************************************/
 /* Domain paging struct initialization. */
-int paging_domain_init(struct domain *d)
+int paging_domain_init(struct domain *d, unsigned int domcr_flags)
 {
     int rc;
 
@@ -646,7 +646,7 @@ int paging_domain_init(struct domain *d)
     /* The order of the *_init calls below is important, as the later
      * ones may rewrite some common fields.  Shadow pagetables are the
      * default... */
-    shadow_domain_init(d);
+    shadow_domain_init(d, domcr_flags);
 
     /* ... but we will use hardware assistance if it's available. */
     if ( hap_enabled(d) )
index 6dfcb7698bcf1880cdde8fe1c68724d30273bcd2..577d97a696af0ff3b1d9f3017cb1f0b87fb3bd8e 100644 (file)
@@ -43,7 +43,7 @@ DEFINE_PER_CPU(uint32_t,trace_shadow_path_flags);
 
 /* Set up the shadow-specific parts of a domain struct at start of day.
  * Called for every domain from arch_domain_create() */
-void shadow_domain_init(struct domain *d)
+void shadow_domain_init(struct domain *d, unsigned int domcr_flags)
 {
     int i;
     shadow_lock_init(d);
@@ -58,6 +58,7 @@ void shadow_domain_init(struct domain *d)
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     d->arch.paging.shadow.oos_active = 0;
+    d->arch.paging.shadow.oos_off = (domcr_flags & DOMCRF_oos_off) ?  1 : 0;
 #endif
 }
 
@@ -3023,7 +3024,7 @@ static void sh_update_paging_modes(struct vcpu *v)
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     /* We need to check that all the vcpus have paging enabled to
      * unsync PTs. */
-    if ( is_hvm_domain(d) )
+    if ( is_hvm_domain(d) && !d->arch.paging.shadow.oos_off )
     {
         int pe = 1;
         struct vcpu *vptr;
index 65ccf2dacfb068d14a4a4c733b9c26ab21b5a3d3..44a18ab1ec602db1c3f064c6a668ef17303617d2 100644 (file)
@@ -393,7 +393,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
         if ( supervisor_mode_kernel ||
              (op->u.createdomain.flags &
              ~(XEN_DOMCTL_CDF_hvm_guest | XEN_DOMCTL_CDF_hap |
-               XEN_DOMCTL_CDF_s3_integrity)) )
+               XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off)) )
             break;
 
         dom = op->domain;
@@ -427,6 +427,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
             domcr_flags |= DOMCRF_hap;
         if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_s3_integrity )
             domcr_flags |= DOMCRF_s3_integrity;
+        if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_oos_off )
+            domcr_flags |= DOMCRF_oos_off;
 
         ret = -ENOMEM;
         d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref);
index 3ecc3bf873139bb7bb30d0e637cc5b05d6da2749..1023c9596528e81b9e7ad03465e455691c4a8c41 100644 (file)
@@ -104,6 +104,7 @@ struct shadow_domain {
 
     /* OOS */
     int oos_active;
+    int oos_off;
 };
 
 struct shadow_vcpu {
index a83772e85f609aa873440168f563a1b48f911652..fca130b43ac39bd0e87f901313d94ab8e869e5e9 100644 (file)
@@ -200,7 +200,7 @@ void paging_vcpu_init(struct vcpu *v);
 
 /* Set up the paging-assistance-specific parts of a domain struct at
  * start of day.  Called for every domain from arch_domain_create() */
-int paging_domain_init(struct domain *d);
+int paging_domain_init(struct domain *d, unsigned int domcr_flags);
 
 /* Handler for paging-control ops: operations from user-space to enable
  * and disable ephemeral shadow modes (test mode and log-dirty mode) and
index 380c8fd1ef204608dd9fe3b99c193e86ce61c616..e7dc66cf09cfcd3211148635af4cdbb2f4090cf4 100644 (file)
@@ -53,7 +53,7 @@
 
 /* Set up the shadow-specific parts of a domain struct at start of day.
  * Called from paging_domain_init(). */
-void shadow_domain_init(struct domain *d);
+void shadow_domain_init(struct domain *d, unsigned int domcr_flags);
 
 /* Setup the shadow-specific parts of a vcpu struct. It is called by
  * paging_vcpu_init() in paging.c */
index 0a8c3727969185ee717f101db8ce0ba220407f57..fb60344505b75bbb8a8a35c615da84fe40308685 100644 (file)
@@ -60,6 +60,9 @@ struct xen_domctl_createdomain {
 #define _XEN_DOMCTL_CDF_s3_integrity  2
 #define XEN_DOMCTL_CDF_s3_integrity   (1U<<_XEN_DOMCTL_CDF_s3_integrity)
     uint32_t flags;
+ /* Disable out-of-sync shadow page tables? */
+#define _XEN_DOMCTL_CDF_oos_off       3
+#define XEN_DOMCTL_CDF_oos_off        (1U<<_XEN_DOMCTL_CDF_oos_off)
 };
 typedef struct xen_domctl_createdomain xen_domctl_createdomain_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_createdomain_t);
index 3bf3a6aacde5e7c7d99b7589f941c13b19eeee99..a8fe8de126f767da8988685af6d9ce5bd399610b 100644 (file)
@@ -364,6 +364,9 @@ struct domain *domain_create(
  /* DOMCRF_dummy: Create a dummy domain (not scheduled; not on domain list) */
 #define _DOMCRF_dummy         3
 #define DOMCRF_dummy          (1U<<_DOMCRF_dummy)
+ /* DOMCRF_oos_off: dont use out-of-sync optimization for shadow page tables */
+#define _DOMCRF_oos_off         4
+#define DOMCRF_oos_off          (1U<<_DOMCRF_oos_off)
 
 /*
  * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().